package com.wenhai.concurrency.thread;

import java.util.ArrayDeque;
import java.util.Queue;

/**
 * @ClassName ConsumerDemo
 * @Description
 * @Author 谢文海
 * @Date 2021/4/8 1:03
 * @Version 1.0
 **/
public class ConsumerDemo {
    public static void main(String[] args) throws InterruptedException {
        Queue<Integer> queue = new ArrayDeque<>();
        Consumer consumer = new Consumer(queue);
        Producer producer = new Producer(queue, 20);
        new Thread(()->{
            for (int i = 0; i < 1000; i++) {
                consumer.consumer();
            }

        }).start();

        new Thread(()->{
            for (int i = 0; i < 1000; i++) {
                consumer.consumer();
            }

        }).start();
        new Thread(()->{
            for (int i = 0; i < 1000; i++) {
                producer.supply(i);
            }
        }).start();
        Thread.sleep(100000);
    }
}
